home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14970 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: noc.netcom.net!news
  2. From: Tarang Deshpande <tarang@willows.com>
  3. Newsgroups: comp.lang.c,comp.lang.c++
  4. Subject: Re: H E L P
  5. Date: Tue, 02 Apr 1996 15:07:02 -0800
  6. Organization: NETCOM Network Operations
  7. Message-ID: <3161B316.3345@willows.com>
  8. References: <N.040296.013047.18@DynamicPPP-185.HIP.CAM.ORG>
  9. NNTP-Posting-Host: daffy.willows.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0GoldB2 (Win95; I)
  14.  
  15. ramrod@cam.org wrote:
  16. > Could anyone please tell me how to write the following program.
  17. > Using nested looping, the output is supposed to look like this.
  18. > Please enter your age in years (0 to end the program): 10
  19. > Happy Birthday To You
  20. > You are 10 Years Old
  21. > \x01\x01\x01\x01\x01\x01\x0\x01\x01\x01(ten happy faces)
  22. > The part that I am having a hard time with is the part that
  23. > whatever number I enter for the age, I'm supposed to get the same number
  24. > of happy faces, automatically.  For example If I say I am 45 years old,
  25. > then the program should show 45 happy faces.
  26.  
  27. void main ()
  28. {
  29.  
  30.     int    Years;
  31.     int    HappyFace;
  32.  
  33.     do
  34.     {
  35.         printf ( "Please enter your age in years (0 to end the program): " );
  36.         scanf ( "%d" &Years );
  37.         if ( Years )
  38.         {
  39.             printf ( "Happy Birthday To You\n" );
  40.             printf ( "You are %d Years Old\n", Years );
  41.             for ( HappyFace = 0; HappyFace < Years; HappyFace++ )
  42.                 printf ( "%c", ( char ) 1 );
  43.         }
  44.     } while ( Years );
  45.  
  46. }
  47.